#include "imageset.h"
#include "stitcher.h"
#include "boost/foreach.hpp"
#include "inputimage.h"

using namespace std;
using namespace cshotel;
using namespace boost;

void ImageSet::addImage(boost::shared_ptr<InputImage> newImage) {
    images.push_back(newImage);
}

const vector<shared_ptr<InputImage> >& ImageSet::getImages() {
    return images;
}

ImageSet::BoundingBox ImageSet::getBoundingBox() {
    // calculate the global bounding box
    double minX = 100000000, minY = 1000000000, maxX = -100000000, maxY = -100000000;
    foreach(shared_ptr<InputImage> img, images) {
        minX = min(minX, img->getTransformedVersionOffset().x);
        maxX = max(maxX, img->getTransformedVersionOffset().x + img->getTransformedVersionImageSize().width);
        minY = min(minY, img->getTransformedVersionOffset().y);
        maxY = max(maxY, img->getTransformedVersionOffset().y + img->getTransformedVersionImageSize().height);
    }
    return BoundingBox(minX, minY, maxX - minX, maxY - minY);
}

int ImageSet::getSize() {
    return images.size();
}

